<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p ref="getMsg">{{msg}}</p>
        <h2 v-if="msg1">{{msg1}}</h2>
        <h2 v-if="msg2">{{msg2}}</h2>
        <h2 v-if="msg3">{{msg3}}</h2>
        <button @click="test">test nextTick</button>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        let vm = new Vue({
            el:"#app",
            data:{
                msg:'空调装上了，都想穿羽绒服了！！',
                msg1:'',
                msg2:'',
                msg3:''
            },
            methods: {
                test(){
                    this.msg = '闰土发毒誓，我要好好学习，天天向上，打雷了！！'
                    // this.msg1 = this.msg;
                    this.msg1 = this.$refs.getMsg.innerHTML;
                    // 在DOM更新结束之后执行回调函数，得到的是更新过后的DOM
                    this.$nextTick(()=>{
                        this.msg2 = this.$refs.getMsg.innerHTML;
                    })
                }
            },
        })
        console.log(vm);
        console.dir(Vue);
        vm.msg = 'xx';
        Vue.nextTick(()=>{
            // console.log(this);
            console.log(vm.$refs.getMsg.innerHTML);
        })
    </script>
</body>
</html>